package com.xuhf.delay;

import com.xuhf.config.Config;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;

public class Producer01 {

    public static void main(String[] args) throws Exception {
        DefaultMQProducer producer = new DefaultMQProducer(Config.PRODUCER_GROUP);
        producer.setNamesrvAddr(Config.NAMESRV_ADDR);
        producer.start();
        Message message = new Message("06-delay", "delay message".getBytes());
        message.setDelayTimeLevel(3);
        SendResult sendResult = producer.send(message);
        System.out.println("生产者发送消息：" + sendResult.getMsgId() + "，发送状态：" + sendResult.getSendStatus());
        // 关闭生产者
        producer.shutdown();
    }
}
